package com.golxen.framework.event.condition;


import com.golxen.framework.activity.ActivityMgr;
import com.golxen.framework.activity.ActivityModule;
import com.golxen.framework.activity.BaseActivityData;
import com.golxen.framework.event.BaseEventArg;
import com.golxen.framework.event.IEventListener;
import com.golxen.framework.event.condition.dao.entity.ActivityConditionInfo;
import com.golxen.framework.activity.dao.entity.ActivityInfo;
import com.golxen.framework.event.condition.dao.entity.UserActivityConditionData;
import com.golxen.framework.event.eGamePlayerEventType;

public abstract class BaseActivityCondition extends BaseCondition {

	protected BaseActivityData baseActivityData;

	public BaseActivityCondition(ActivityConditionInfo activityConditionInfo,
								 BaseActivityData baseActivityData,UserActivityConditionData userActivityConditionData) {
		super(baseActivityData.getPlayer(),activityConditionInfo,userActivityConditionData);
		this.baseActivityData = baseActivityData;
	}

	//事件处理实现
	protected abstract void player_EventListenerHandle(Object object);


	protected final String getParam() {
		UserActivityConditionData userActivityConditionData = baseActivityData
				.getUserActivityConditionData(getConditionId());
		return userActivityConditionData.getParam();
	}

	public final void setParam(String param) {
		UserActivityConditionData userActivityConditionData = baseActivityData
				.getUserActivityConditionData(getConditionId());
		userActivityConditionData.setParam(param);
	}


	public final void setModifyTime(long modifyTime) {
		UserActivityConditionData userActivityConditionData = baseActivityData
				.getUserActivityConditionData(getConditionId());
		userActivityConditionData.setModifyTime(modifyTime);
	}


	public void changeValue(Object object) {
		// 活动期间改变值
		ActivityInfo curActivity = ActivityMgr.getActivityInfo(baseActivityData.getActivityId());
		if (canChange(curActivity)) {
			player_EventListenerHandle(object);
		}
	}

	// 是否可变更
	public boolean canChange(ActivityInfo curActivity) {
		if (ActivityMgr.isActivityInTime(curActivity)) {
			return true;
		}

		return false;
	}


}
